package com.mz.ozy.activity.me;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.just.agentweb.AgentWeb;
import com.mz.ozy.R;
import com.mz.ozy.base.BaseActivity;
import com.mz.ozy.utils.AppUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

public class CustomerServiceActivity extends BaseActivity {

    @BindView(R.id.ll_H5Page)
    LinearLayout mLlH5Page;
    AgentWeb agentWeb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_customer_service);
        ButterKnife.bind(this);
        initTitle();
//        setTitleBarMargin();
        tvCenterTitle.setText(R.string.me_kf);
        tvTitle.setVisibility(View.GONE);
        agentWeb = AgentWeb.with(this)
                .setAgentWebParent(mLlH5Page, new LinearLayout.LayoutParams(-1, -1))
                .useDefaultIndicator()
                .createAgentWeb()
                .ready()
                .go("https://chat.sobot.com/chat/h5/v2/index.html?sysnum=6afa5cf53b2d407ebfb8cf6fd3de5fc3&source=2");

    }

    /**
     * 设置沉浸式状态栏时，要把标题栏往下移动状态栏的高度
     */
    public void setTitleBarMargin() {
        int length = AppUtils.getStatusBarHeight(this);
        //注意布局是哪种Layout
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(titleBar.getLayoutParams());
        lp.setMargins(0, length, 0, 0);
        titleBar.setLayoutParams(lp);
    }

    @Override
    protected void onPause() {
        agentWeb.getWebLifeCycle().onPause();
        super.onPause();
    }

    @Override
    protected void onResume() {
        agentWeb.getWebLifeCycle().onResume();
        super.onResume();
    }

    @Override
    protected void onDestroy() {
        agentWeb.getWebLifeCycle().onDestroy();
        super.onDestroy();
    }
}
